<?php
/*
 * MiniMe - a minimalistic OStatus complient microblogging tool
 * Copyright (C) 2010, Tuomas Koski - koski.tuomas@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @author     Tuomas Koski <koski.tuomas@gmail.com>
 * @copyright  Tuomas Koski
 * @license    http://www.gnu.org/licenses/lgpl.txt
 */

require_once '../classes/minime.php';
MiniMe::initialize();

if(!isset($_GET['controller'])) {
    header('HTTP/1.0 404 Not Found');
    echo "<pre>";
    echo "Set at least the controller! For example to get the lrdd of the user, call:\n";
    echo "</pre>";
    $url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?controller=lrdd&uri=" . urlencode("acct:koski-1@lobstermonster.org");
    echo "<a href='" . $url . "'>" . $url . "</a>";
    exit;
}

try {

    $controller = MiniMe::getController($_GET['controller']);
    $controller->execute();
    $controller->outputHeaders();
    $controller->outputBody();

} catch (Exception $e) {
    header('HTTP/1.0 500 Internal Server Error');
    $data =  "<pre>";
    $data .= $e->getMessage();
    file_put_contents ("/tmp/output-error.data", $data);
    echo $data;
}

